package com.example.riskmanage.service.impl;

import com.alibaba.fastjson.JSON;

import com.example.riskmanage.bean.NHistorylist;
import com.example.riskmanage.dao.NHistorylistDao;
import com.example.riskmanage.service.NHistorylistManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class NHistorylistManagerImpl implements NHistorylistManager {
    @Autowired
    NHistorylistDao nhistorylistDao;

    @Override
    public String getNHistorylistService(Integer uid){
        HashMap<String,Object> map = new HashMap<>();

        //1.调用dao层接口获取数据
        List<NHistorylist> nhistorylistList = nhistorylistDao.findAllByUid(uid);
        //2.将处理的数据封装到map
        map.put("nhistorylistList",nhistorylistList);
        map.put("flag",true);


        String respJSON = JSON.toJSONString(map);
        return respJSON;
    }
    @Override
    public String addNHistorylistService(NHistorylist nhistorylist){

        nhistorylistDao.save(nhistorylist);
        return "ok";
    }
    @Override
    public String deleteNHistorylistService(Integer id){
        nhistorylistDao.deleteById(id);
        return "ok";
    }


}
